package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.function.BiConsumer;

public class 日志统计 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=100010;
       static int n,d,k;
       public static void main(String[] ss) throws IOException {
		       ss=br.readLine().split(" ");
		       n=Integer.parseInt(ss[0]);d=Integer.parseInt(ss[1]);k=Integer.parseInt(ss[2]);
		       HashMap<Integer, List<Integer>> map = new HashMap<Integer,List<Integer>>();
		       while(n-->0){
		    	    ss=br.readLine().split(" ");
		    	    int ts=Integer.parseInt(ss[0]),id=Integer.parseInt(ss[1]);
		    	    List<Integer>cms= map.get(id);
		    	    if(cms==null)cms=new ArrayList<Integer>();
		    	    cms.add(ts);
		    	    map.put(id,cms);
		       }
		       final List<Integer>res=new ArrayList<Integer>();
		       map.forEach(new BiConsumer<Integer,List<Integer>>(){
                
				public void accept(Integer id, List<Integer> u) {
					// TODO Auto-generated method stub
					Collections.sort(u);
					for(int i=0;i<=u.size()-k;i++){
						int t=k+i-1;
						if(u.get(t)-u.get(i)<d){
							res.add(id);
							break;
						}
					}
				}  
			   });
		       Collections.sort(res);
		       for(Integer id:res){
		    	   System.out.println(id);
		       }
	   }
}
